﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;
using HIWSystem.Models;

namespace HIWSystem.Converters
{
    public class TestResultToColor : IValueConverter
    {
        //Source to Target
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value!=null)
            {
                TrackingEntity tEntity = new TrackingEntity();
                try
                {
                    tEntity = (TrackingEntity)value;
                    if (tEntity.Result == "PASS")
                    {
                        return Brushes.Green;
                    }
                    else if (tEntity.Result == "FAIL")
                    {
                        return Brushes.Red;
                    }
                }
                catch 
                {
                    return Binding.DoNothing;
                }
                
            }
            return Binding.DoNothing;
            //throw new NotImplementedException();
        }
        //Target to Source
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // throw new NotImplementedException();
            return Binding.DoNothing;
        }
    }
}
